How can I replace nested if statements with a loop in JavaScript for dynamic searching

visit shbcf.ru